home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / java / magic oracle / magic oracle readme < prev    next >
Encoding:
Text File  |  2000-06-23  |  2.2 KB  |  61 lines

  1. Magic Oracle AppleScript for Java Example 4/9/99
  2.  
  3. This example demonstrates how to script your Java Application using
  4. AppleScript. Functionality mimics the old black billiard ball that you
  5. asked a fortune and then shook vigorously in order to receive a cryptic
  6. reply.
  7.  
  8. It also demonstrates how to create a bean info to enhance the
  9. automatically generated 'aete' created by the introspector.
  10.  
  11. To submit your question to the "Magic Oracle", type your yes or no
  12. question in the text field and click the "Ask Oracle" button, press
  13. return or enter, or grab the ball with your mouse and shake it around
  14. the screen.
  15.  
  16. You may also communicate via AppleScript using the Scriptable Text
  17. Editor.
  18.  
  19. tell application "Magic Oracle" 
  20.    ask Mystic of Main Frame "oracleFrame" parameters {"Is Java cool?"} 
  21. end tell
  22.  
  23. or using the more straight-forward terminology specified in the
  24. beanInfo:
  25.  
  26. tell application "Magic Oracle" 
  27.    ask Mystic of frame "oracleFrame" question "Is Java cool?" 
  28. end tell
  29.  
  30. The application will perform it's magic and return a string as a
  31. response.
  32.  
  33. How this works:
  34.  
  35. The application has a public method that takes a string parameter and
  36. returns a string.
  37.  
  38. java.lang.String askOracle( java.lang.String question );
  39.  
  40. Terminology for this method is in the aete which was automatically
  41. generated by MRJ, trimmed, edited, and then the 'scsz' resource was
  42. removed to freeze the terminology.
  43.  
  44. MainFrameBeanInfo.java contains a property and a method descriptor. The
  45. property descriptor provides a formal parameter name in the 'aete'. The
  46. method descriptor provides a more descriptive string for the method
  47. "askMystic()" in the 'aete'.
  48.  
  49. If you would like to see the aete generated automatically as specified
  50. by the BeanInfo, make a copy of the Magic Oracle application. Using
  51. ResEdit, replace the aete in the application copy with the aete found in
  52. the MRJ Scripting folder in the MRJ SDK. Make sure that you copy in the
  53. 'scsz' resource so that generation of the 'aete' is activated. You will
  54. now be able to open the application dictionary in the Scriptable Text
  55. Editor and see the results.
  56.  
  57. For more information on AppleScript for Java, consult Technote 1162:
  58. Introduction to MRJ Scripting with AppleScript for Java located at:
  59.  
  60. <http://devworld.apple.com/technotes/java/java-1.html>
  61.